← Back to issue list

snapcraft's nodejs plugin does not refresh the global, user cache before installing dependencies

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1660614
Type
issue
State
open
Author
~gvancuts
Labels
plugins
Created
2017-01-31 12:54:52.069055+00:00
Updated
2017-01-31 15:17:13.551575+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

When using the nodejs plugin of snapcraft, it installs the required package and its dependencies using the "--cache-min" parameter (see [1]). That basically means the npm cache will not be refreshed before attempting the operation and that can result in errors if the following scenario occurs: - Your snap depends on the nodejs "foo" module, initially version 1. - Version 1 of your snap depends on "foo" version 1 and can successfully be built. A few days/weeks later: - You update your snap to version 2 and now require "foo" version 2 But now building your snap fails with an error indicating that "foo" version 2 is not available from the npm registry. That message is confusing because if you check the online npm registry, you will see that it is, in fact, available. The error comes from the fact that 'npm' used an outdated version of the cache that is availabe (and was built before "foo" version 2 was available). For a more complete (and real) error message, see [2] below. A manual workaround is to check the status of the npm cache on your build system (`npm outdated`) and update it (`npm update`) if needed. It would be desirable to remove that option (or find a different mechanism in case snapcraft should also be able to operate offline). [1] https://github.com/snapcore/snapcraft/blob/31c45dd51f73f9065894fda36bc0e339f023418b/snapcraft/plugins/nodejs.py#L133 [2] gvancuts@gvancuts-nuc:~/iot-rest-api-server$ snapcraft Preparing to pull meta-iot-web Pulling meta-iot-web From https://github.com/01org/iot-rest-api-server * branch master -> FETCH_HEAD Already up-to-date. Downloading 'node-v4.4.4-linux-x64.tar.gz'[===========================================================================================================================================================] 100% npm --cache-min=Infinity install npm ERR! Linux 4.4.0-59-generic npm ERR! argv "/home/gvancuts/iot-rest-api-server/parts/meta-iot-web/install/bin/node" "/home/gvancuts/iot-rest-api-server/parts/meta-iot-web/install/bin/npm" "--cache-min=Infinity" "install" npm ERR! node v4.4.4 npm ERR! npm v2.15.1 npm ERR! code ETARGET npm ERR! notarget No compatible version found: iotivity-node@'>=1.2.0-1 <2.0.0' npm ERR! notarget Valid install targets: npm ERR! notarget ["0.9.2-0","0.9.2-1","1.0.0-0","1.0.0-1","1.0.0-2","1.0.0-3","1.0.0-4","1.0.1-0","1.0.1-1","1.1.0-1","1.1.0-2","1.1.0-3","1.1.0-4","1.1.0-5","1.1.1-0","1.1.1-1","1.1.1-2","1.1.1-3","1.2.0-0"] npm ERR! notarget npm ERR! notarget This is most likely not a problem with npm itself. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist. npm ERR! notarget npm ERR! notarget It was specified as a dependency of 'iot-rest-api-server' npm ERR! notarget npm ERR! Please include the following file with any support request: npm ERR! /home/gvancuts/iot-rest-api-server/parts/meta-iot-web/src/npm-debug.log Command '['/bin/sh', '/tmp/tmpmchipfnc', 'npm', '--cache-min=Infinity', 'install']' returned non-zero exit status 1

Evaluation history

No evaluation history available.